package ma.controller.panels.auxillary;

import java.awt.event.ActionListener;

import ma.view.gui.auxillary.InformationPanel;

/**
 * The class {@code CtrInformationPanel} controls the behavior of the
 * information panel.
 * @author Oliver Eckstein
 *
 */
public class CtrInformationPanel {
    
    private InformationPanel infoPanel;
    
    /**
     * To create a new instance of a {@code CtrInformationPanel}.
     */
    public CtrInformationPanel() {
        infoPanel = new InformationPanel();
    }
    
    /**
     * To enable the calculate button of a manufacturing method.
     */
    public void enableCalculation() {
        infoPanel.getBtnCalculate().setEnabled(true);
    }
    
    /**
     * To disable the calculate button of a manufacturing method.
     */
    public void disableCalculation() {
        infoPanel.getBtnCalculate().setEnabled(false);        
    }
    
    /**
     * To enable the button which confirms the data input.
     */
    public void enableStoreData() {
        infoPanel.getBtnStoreData().setEnabled(true);
    }
    
    /**
     * To disable the button which confirms the data input.
     */
    public void disableStoreData() {
        infoPanel.getBtnStoreData().setEnabled(false);
    }
    
    /**
     * To enable the button which starts the calculation of the
     * {@code EBenchmark}.
     */
    public void enableCalculateAll() {
        infoPanel.getBtnCalculateAll().setEnabled(true);
    }
    
    /**
     * To disable the button which starts the calculation of the
     * {@code EBenchmark}.
     */
    public void disableCalculateAll() {
        infoPanel.getBtnCalculateAll().setEnabled(false);
    }
    
    /**
     * To register an {@code ActionListener} for the button to store the
     * data of a {@code ManufacturingMethod}.
     * @param l the {@code ActionListener} to be registered.
     */
    public void registerStoreDataListener(ActionListener l) {
        infoPanel.getBtnStoreData().addActionListener(l);
    }
    
    /**
     * To remove the {@code ActionListener} for the button to store the
     * data of a {@code ManufacturingMethod}.
     * @param l the {@code ActionListener} to be removed.
     */
    public void removeStoreDataListener(ActionListener l) {
        infoPanel.getBtnStoreData().removeActionListener(l);
    }
    
    /**
     * To register an {@code ActionListener} for the button to confirm setting
     * up a {@code ManufacturingMethod}.
     * @param l the {@code ActionListener} to be registered.
     */
    public void registerSetupConfirmListener(ActionListener l) {
        infoPanel.getBtnSetupConfirm().addActionListener(l);
    }
    
    /**
     * To register an {@code ActionListener} for the button to calculate a
     * {@code ManufacturingMethod}.
     * @param l the {@code ActionListener} to be registered.
     */
    public void registerCalculateListener (ActionListener l) {
        infoPanel.getBtnCalculate().addActionListener(l);
    }
    
    /**
     * To remove the {@code ActionListener} for the button to calculate a
     * {@code ManufacturingMethod}.
     * @param l the {@code ActionListener} to be removed.
     */
    public void removeCalculateListener(ActionListener l) {
        infoPanel.getBtnCalculate().removeActionListener(l);
    }
    
    /**
     * To register an {@code ActionListener} for the button to calculate the
     * {@code EBenchmark}.
     * @param l the {@code ActionListener} to be registered.
     */
    public void registerCalculateAllListener (ActionListener l) {
        infoPanel.getBtnCalculateAll().addActionListener(l);
    }
    
    /**
     * To register an {@code ActionListener} for the button to close the main
     * results tab.
     * @param l the {@code ActionListener} to be registered.
     */
    public void registerCloseResultsListener (ActionListener l) {
        infoPanel.getBtnCloseResults().addActionListener(l);
    }

    /**
     * To get the information panel.
     * @return the information panel.
     */
    public InformationPanel getView() {
        return infoPanel;
    }
}
